package org.example.gochannel;

import java.util.Random;

public class SelectChGroup {
    public static Random random = new Random();


    public static void watchAndExecOnce(long oft, ChannelExecWrapper<?>... wrappers) throws InterruptedException {
        int i = Math.abs(random.nextInt()) % wrappers.length;
        for (; ; i = (i + 1) % wrappers.length) {
            if (wrappers[i].watchAndExecOnce(oft)) {
                return;
            }
        }
    }

    public static void watchAndExecOnce(ChannelExecWrapper<?>... wrappers) throws InterruptedException {
        watchAndExecOnce(10, wrappers);
    }
}
